<?PHP
/*
  Plugin to handle simple http and ftp downloads
  Developed by seth <xd dot seth at gmail dot com - http://elrincondeseth.wordpress.com>
*/


function default_download($url)
{
    $file = downloadUrl($url);
    if(parse_url($url, PHP_URL_SCHEME)=='ftp'){
       
        if($file['content']) {
            return array(
                            'status' => STATUS_DOWNLOADED,
                            'content' => $file['content']
            );
        }else{
            return array(
                            'status' => STATUS_ERROR,
                            'status_error' => 'Download error. Response code #'.$file['code'],
            );
        }
        
    }else{
        
        if(($file['code']<200) or ($file['code']>299)) {
            return array(
                            'status' => STATUS_ERROR,
                            'status_error' => 'Download error. Response code #'.$file['code'],
            );
        }else{
            return array(
                            'status' => STATUS_DOWNLOADED,
                            'content' => $file['content']
            );
        }
    
    }
}

/*
 This function returns the file name
*/
function default_getName($url)
{
    return strpos($url,'?') ? strstr(basename($url),'?',true) : basename($url);

}
?>